package com.qianfeng.xiaxk.activity;

import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.qianfeng.xiaxk.R;
import com.qianfeng.xiaxk.adapter.SingleViewPagerAdapter;

import java.util.ArrayList;
import java.util.List;

@ContentView(R.layout.activity_guide)
public class GuideActivity extends AppCompatActivity implements View.OnClickListener {
    @ViewInject(R.id.guide_container)
    ViewPager guide_container;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewUtils.inject(this);
        initView();
    }

    private void initView() {
        List<View> views = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            View view = getLayoutInflater().inflate(R.layout.single_image_layout, null);
            ImageView img = (ImageView) view.findViewById(R.id.single_image);

            if (i == 0) {
                img.setImageResource(R.mipmap.splash1);
            } else if (i == 1) {
                img.setImageResource(R.mipmap.splash2);
            } else if (i == 2) {
                img.setImageResource(R.mipmap.splash3);
            }else if(i==3){
                img.setImageResource(R.mipmap.splash4);
                TextView guideStart = (TextView) view.findViewById(R.id.guide_start);
                guideStart.setVisibility(View.GONE);
                guideStart.setVisibility(View.VISIBLE);
                guideStart.setOnClickListener(this);
            }
            views.add(view);
        }
        SingleViewPagerAdapter adapter = new SingleViewPagerAdapter(views);
        guide_container.setAdapter(adapter);
    }


    @Override
    public void onClick(View v) {
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }
}
